
Page({
 data:{
  run:[],
  done:[]
 },
 onLoad(){
  var run = this.data.run;
  var done = this.data.done;
  run = wx.getStorageSync('run')||[]
  done = wx.getStorageSync('done')||[]
  this.setData({
    run,done
  })
 },
 toDo(e){
   var value = e.detail.value;
   var run = this.data.run; 
   if(!run.includes(value)&&value!=""){
     run.push(value)
   }
  this.local()
   this.setData({run,value:""})
 },
 toDone(e){
   var index = e.currentTarget.dataset.index;
   var run = this.data.run;
   var done = this.data.done;
   var res = run.splice(index,1)
   done.push(...res)
  this.local()
   this.setData({
     run,done
   })
 },
 toRun(e){
  var index = e.currentTarget.dataset.index;
  var run = this.data.run;
  var done = this.data.done;
  var res = done.splice(index,1)
  run.push(...res)
  this.local()
  this.setData({
    run,done
  })
 },
 toRunDelete(e){
  var index = e.currentTarget.dataset.index;
  var run = this.data.run;
  run.splice(index,1)
  this.local()
  this.setData({
    run
  })
 },
 toDoneDelete(e){
  var index = e.currentTarget.dataset.index;
  var done = this.data.done;
  done.splice(index,1)
  this.local()
  this.setData({
    done
  })
 },
 local(){
  var run = this.data.run;
  var done = this.data.done;
  wx.setStorageSync('run', run)
  wx.setStorageSync('done', done)
 }
})
